package io.renren.service.impl;

import io.renren.dao.SchoolMajorDao;
import io.renren.entity.LowScoreEntity;
import io.renren.entity.ProfessionEntity;
import io.renren.entity.UniversityEntity;
import io.renren.service.SchoolMajorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class SchoolMajorServiceImpl implements SchoolMajorService {

    @Autowired
    SchoolMajorDao schoolMajorDao;

    @Override
    public List getVipUniversitys(Map<String, Object> params) {
        String wenlike = (String) params.get("idWenlike");
        String learnType = (String) params.get("idLearnType");
        String level = (String) params.get("idLevel");
        String wl = wenlike + learnType + level;
        if (level.equals("本科")) {
            // params.remove("idLevel");
            params.put("noInLevel", "专科");
        } else {
            //params.remove("idLevel");
            params.put("noInLevel", "本科");
        }

        switch (wl) {
            case "理科普通本科":
                params.put("predictor", "putonglike");
                break;
            case "理科校企合作本科":
                params.put("predictor", "xiaoqihezuolike");
                break;
            case "理科中外合作本科":
                params.put("predictor", "zhongwaihezuolike");
                break;
            case "理科3+2连读本科":
                params.put("predictor", "liandulike");
                break;
            case "理科春考本科":
                params.put("predictor", "chunkaolike");
                break;
            case "理科艺术本科":
                params.put("predictor", "yishulike");
                break;
            case "文科普通本科":
                params.put("predictor", "putongwenke");
                break;
            case "文科校企合作本科":
                params.put("predictor", "xiaoqihezuowenke");
                break;
            case "文科中外合作本科":
                params.put("predictor", "zhongwaihezuowenke");
                break;
            case "文科3+2连读本科":
                params.put("predictor", "lianduwenke");
                break;
            case "文科春考本科":
                params.put("predictor", "chunkaowenke");
                break;
            case "文科艺术本科":
                params.put("predictor", "yishuwenke");
                break;
            case "理科普通专科":
                params.put("predictor", "zhuankeputonglike");
                break;
            case "理科校企合作专科":
                params.put("predictor", "zhuankexiaoqilike");
                break;
            case "理科中外合作专科":
                params.put("predictor", "zhuankezhongwaihezuolike");
                break;
            case "理科3+2连读专科":
                params.put("predictor", "zhuankeliandulike");
                break;
            case "理科春考专科":
                params.put("predictor", "zhuankechunkaolike");
                break;
            case "理科艺术专科":
                params.put("predictor", "zhuankeyishulike");
                break;
            case "文科普通专科":
                params.put("predictor", "zhuankeputongwenke");
                break;
            case "文科校企合作专科":
                params.put("predictor", "zhuankexiaoqiwenke");
                break;
            case "文科中外合作专科":
                params.put("predictor", "zhuankezhongwaihezuowenke");
                break;
            case "文科3+2连读专科":
                params.put("predictor", "zhuankelianduwenke");
                break;
            case "文科春考专科":
                params.put("predictor", "zhuankechunkaowenke");
                break;
            case "文科艺术专科":
                params.put("predictor", "zhuankeyishuwenke");
                break;

        }
        List<UniversityEntity> l = schoolMajorDao.getVipUniversitys(params);
        for (UniversityEntity u : l) {
            if (u.getName().length() > 9) {
                u.setNameForShow(u.getName().substring(0, 9) + "...");
            }else{
                u.setNameForShow(u.getName());
            }
            if (u.getCities() != null && u.getCities().length() > 0) {
                if ((u.getCities().substring(u.getCities().length() - 1, u.getCities().length())).equals(","))
                    u.setCities(u.getCities().substring(0, u.getCities().length() - 1));
            }
        }
        return l;
    }

    @Override
    public List getUniversitys(Map<String, Object> params) {
        String wenlike = (String) params.get("idWenlike");
        String learnType = (String) params.get("idLearnType");
        String level = (String) params.get("idLevel");
        String wl = wenlike + learnType + level;
        if (level.equals("本科")) {
            // params.remove("idLevel");
            params.put("noInLevel", "专科");
        } else {
            //params.remove("idLevel");
            params.put("noInLevel", "本科");
        }

        switch (wl) {
            case "理科普通本科":
                params.put("predictor", "putonglike");
                break;
            case "理科校企合作本科":
                params.put("predictor", "xiaoqihezuolike");
                break;
            case "理科中外合作本科":
                params.put("predictor", "zhongwaihezuolike");
                break;
            case "理科3+2连读本科":
                params.put("predictor", "liandulike");
                break;
            case "理科春考本科":
                params.put("predictor", "chunkaolike");
                break;
            case "理科艺术本科":
                params.put("predictor", "yishulike");
                break;
            case "文科普通本科":
                params.put("predictor", "putongwenke");
                break;
            case "文科校企合作本科":
                params.put("predictor", "xiaoqihezuowenke");
                break;
            case "文科中外合作本科":
                params.put("predictor", "zhongwaihezuowenke");
                break;
            case "文科3+2连读本科":
                params.put("predictor", "lianduwenke");
                break;
            case "文科春考本科":
                params.put("predictor", "chunkaowenke");
                break;
            case "文科艺术本科":
                params.put("predictor", "yishuwenke");
                break;
            case "理科普通专科":
                params.put("predictor", "zhuankeputonglike");
                break;
            case "理科校企合作专科":
                params.put("predictor", "zhuankexiaoqilike");
                break;
            case "理科中外合作专科":
                params.put("predictor", "zhuankezhongwaihezuolike");
                break;
            case "理科3+2连读专科":
                params.put("predictor", "zhuankeliandulike");
                break;
            case "理科春考专科":
                params.put("predictor", "zhuankechunkaolike");
                break;
            case "理科艺术专科":
                params.put("predictor", "zhuankeyishulike");
                break;
            case "文科普通专科":
                params.put("predictor", "zhuankeputongwenke");
                break;
            case "文科校企合作专科":
                params.put("predictor", "zhuankexiaoqiwenke");
                break;
            case "文科中外合作专科":
                params.put("predictor", "zhuankezhongwaihezuowenke");
                break;
            case "文科3+2连读专科":
                params.put("predictor", "zhuankelianduwenke");
                break;
            case "文科春考专科":
                params.put("predictor", "zhuankechunkaowenke");
                break;
            case "文科艺术专科":
                params.put("predictor", "zhuankeyishuwenke");
                break;

        }
        List<UniversityEntity> l = schoolMajorDao.getUniversitys(params);
        for (UniversityEntity u : l) {
            if (u.getName().length() > 9) {
                u.setNameForShow(u.getName().substring(0, 9) + "...");
            }else{
                u.setNameForShow(u.getName());
            }
            if (u.getPredictor() != null) {
                String predictor = u.getPredictor().toString();
                String a = predictor.toString();
                String score = a.substring(0, 1);
                predictor = score + "**";
                u.setPredictor(predictor);

            }
            if (u.getCities() != null && u.getCities().length() > 0) {
                if ((u.getCities().substring(u.getCities().length() - 1, u.getCities().length())).equals(","))
                    u.setCities(u.getCities().substring(0, u.getCities().length() - 1));
            }
        }
        return l;
    }


    @Override
    public List getLowscore(Map<String, Object> params) {
        List<LowScoreEntity> l = schoolMajorDao.getLowscore(params);
        return l;
    }

    @Override
    public List getProfression(Map<String, Object> params) {
        List<ProfessionEntity> l = schoolMajorDao.getProfression(params);
        return l;
    }

}
